<body>
    <form id="my-form">
        <div id="tools" class="datagrid-toolbar">
            <input type="hidden" name="type" id="type" value="23">
            <a id="closeBtn" name="backOk" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-close"
                plain="true"><span class="l-btn-left"><span
                        class="l-btn-text icon-close l-btn-icon-left">关闭</span></span></a>
        </div>
        <p id="errorMsg" style="color:red;margin-top:5px;"></p>
        <table class="formTable">
            <tbody>
                <tr>
                    <td class="tdc1" style="width:160px;">
                        申请人：
                    </td>
                    <td colspan="3">
                        <input type="text" name="applyUserName" id="applyUserName" data-options="required:true"
                            class="easyui-validatebox validatebox-text" readonly="">
                        <input type="hidden" name="applyUserId" id="applyUserId" value="982">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        供应商评审申请表：
                    </td>
                    <td colspan="3">
                        <input type="text" name="projectName" id="projectName" data-options="required:true"
                            class="easyui-validatebox validatebox-text" readonly="">
                        <input type="hidden" name="projectId" id="projectId" value="224">
                        <span style="margin-left:2px;" id="toView"><a
                                href="javascript:viewProject(224);">查看详情</a></span>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        审批领导：
                    </td>
                    <td colspan="3">
                        <input type="text" name="approvalNames" id="approvalNames"
                            class="easyui-validatebox validatebox-text" readonly="">
                        <input type="hidden" name="approvalIds" id="approvalIds" value="572,566,697">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        财务：
                    </td>
                    <td colspan="3">
                        <input type="text" name="financename" id="financename"
                            class="easyui-validatebox validatebox-text" readonly="">
                        <input type="hidden" name="financeid" id="financeid" value="574">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        总经理：
                    </td>
                    <td colspan="3">
                        <input type="text" name="managername" id="managername"
                            class="easyui-validatebox validatebox-text" readonly="">
                        <input type="hidden" name="managerid" id="managerid" value="">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        董事长：
                    </td>
                    <td colspan="3">
                        <input type="text" name="presidentname" id="presidentname"
                            class="easyui-validatebox validatebox-text" readonly="">
                        <input type="hidden" name="presidentid" id="presidentid" value="">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        签约单位名称：
                    </td>
                    <td colspan="3">
                        <input type="text" name="companyName" id="companyName" readonly="" data-options="required:true"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        合同名称：
                    </td>
                    <td colspan="3">
                        <input type="text" name="contractName" id="contractName" readonly=""
                            data-options="required:true" class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        合同金额：
                    </td>
                    <td style="width:36%">
                        <input type="text" id="money" readonly="" data-options="required:true"
                            class="easyui-numberbox numberbox-f validatebox-text" precision="2"
                            numberboxname="money"><input type="hidden" name="money" value="437672.88">
                    </td>
                    <td class="tdc1" style="width:160px">
                        合同类型：
                    </td>
                    <td>
                        <input type="text" name="contractType" id="contractType" readonly=""
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr id="othertr" style="">
                    <td class="tdc1">
                        其他：
                    </td>
                    <td>
                        <input type="text" name="otherthing" id="otherthing" readonly=""
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        合同内容：
                    </td>
                    <td>
                        <textarea name="content" id="content" readonly="" style="width:70%;height:60px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        付款时间：
                    </td>
                    <td>
                        <input type="text" name="payDateStr" id="payDateStr" readonly="readonly"
                            class="easyui-validatebox validatebox-text">
                    </td>
                    <td class="tdc1">
                        付款方式：
                    </td>
                    <td>
                        <input type="text" name="payType" id="payType" readonly="readonly"
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        发票类型：
                    </td>
                    <td>
                        <input type="text" name="invoiceType" id="invoiceType" readonly=""
                            class="easyui-validatebox validatebox-text">
                    </td>

                    <td class="tdc1">
                        税点：
                    </td>
                    <td>
                        <input type="text" name="taxPoint" id="taxPoint" readonly=""
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        开票内容：
                    </td>
                    <td>
                        <input type="text" name="invoiceContent" id="invoiceContent" readonly=""
                            class="easyui-validatebox validatebox-text">
                    </td>
                    <td class="tdc1">
                        开票内容(其他)：
                    </td>
                    <td>
                        <input type="text" name="other" id="other" readonly=""
                            class="easyui-validatebox validatebox-text">
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        质保期限：
                    </td>
                    <td colspan="3">
                        <textarea name="warrantyperiod" id="warrantyperiod" readonly=""
                            style="width:70%;height:70px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="tdc1">
                        相关附件：
                    </td>
                    <td>
                        <div style="margin-left:10px;">
                            <div id="showFiles">
                                <div style="margin-top:8px;margin-bottom:8px;">启迪之星人工智能孵化器展厅设计.pdf<a
                                        style="margin-left:10px" href="javascript:" onclick="downfile(778087)">下载</a>
                                    <div style="margin-top:8px;margin-bottom:8px;">启迪展厅及服务器机房施工合同-朝尚2024-11-已修改.docx<a
                                            style="margin-left:10px" href="javascript:"
                                            onclick="downfile(778086)">下载</a>
                                        <div style="margin-top:8px;margin-bottom:8px;">露台-原现场图.png<a
                                                style="margin-left:10px" href="javascript:"
                                                onclick="downfile(778085)">下载</a>
                                            <div style="margin-top:8px;margin-bottom:8px;">法人身份证-刘媛媛.pdf<a
                                                    style="margin-left:10px" href="javascript:"
                                                    onclick="downfile(778084)">下载</a>
                                                <div style="margin-top:8px;margin-bottom:8px;">朝尚营业执照.pdf<a
                                                        style="margin-left:10px" href="javascript:"
                                                        onclick="downfile(778083)">下载</a>
                                                    <div style="margin-top:8px;margin-bottom:8px;">
                                                        20241101展厅服务器机房报价-新.pdf<a style="margin-left:10px"
                                                            href="javascript:" onclick="downfile(778082)">下载</a></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
        <div style="margin-left:10px;">
            <div id="showRecords">
                <div style="margin-top:8px;margin-bottom:8px;">审核人：王博宇<span style="margin-left:15px;">审核时间：2025-10-15
                        11:11:33</span><span style="margin-left:15px;">审核选项：同意</span><span
                        style="margin-left:15px;">审核意见：同意</span></div>
                <div style="margin-top:8px;margin-bottom:8px;">审核人：韩威<span style="margin-left:15px;">审核时间：2025-10-15
                        08:53:18</span><span style="margin-left:15px;">审核选项：同意</span><span
                        style="margin-left:15px;">审核意见：同意</span></div>
                <div style="margin-top:8px;margin-bottom:8px;">审核人：王维<span style="margin-left:15px;">审核时间：2025-10-15
                        08:52:31</span><span style="margin-left:15px;">审核选项：同意</span><span
                        style="margin-left:15px;">审核意见：同意</span></div>
                <div style="margin-top:8px;margin-bottom:8px;">审核人：刘新宇<span style="margin-left:15px;">审核时间：2025-10-15
                        16:00:53</span><span style="margin-left:15px;">审核选项：同意</span><span
                        style="margin-left:15px;">审核意见：同意</span></div>
                <div style="margin-top:8px;margin-bottom:8px;">复核人：王博宇<span style="margin-left:15px;">复核时间：2025-10-15
                        18:01:57</span><span style="margin-left:15px;">复核选项：同意</span><span
                        style="margin-left:15px;">复核意见：同意</span></div>
            </div>
        </div>
    </form>


    <script>

        function checkFormMe(form) {

            return $('#my-form').form('validate');
        }

        var type = $.getUrlParam("type");

        $("#type").val(type);

        var p_id = $.getUrlParam("id");
        var objectId = new Date().getTime();
        var process_id = $.getUrlParam("processid");
        if (process_id != null) {
            $.ajax({
                type: "GET",
                url: contextPath + "manager/approvalprocess/getBeanIdByProcessId/" + process_id + "/" + type,
                data: null,
                dataType: "json",
                success: function (data) {
                    if (data && data.handleMsg.status == 1) {
                        p_id = data.id;
                        if (p_id != null) {
                            objectId = p_id;
                        }
                        loadBassModel(p_id);
                    }
                },
                error: function (response) {
                    $.messager.alert("提示", "出错了，请联系管理员!", 'error', function (rt) {
                        $.messager.alert("提示", response.responseText, 'error');
                    });
                }

            });
        } else {

            loadBassModel(p_id);
        }

        function loadBassModel(p_id) {
            var BaseModel = Backbone.Model.extend({ urlRoot: contextPath + 'manager/decorateContract' });
            var baseModel;

            if (p_id == null) {
                baseModel = new BaseModel();
            } else {
                baseModel = new BaseModel({ id: p_id, i: new Date().getTime() });
            }
            var baseView = new BaseView({ el: $("#my-form"), model: baseModel });
            if (p_id != null) {
                baseView.doLoad(loadMe);
            }

        }

        function loadMe(model, response, options) {
            if (model.get("approvalProcess")) {
                if (model.get("approvalProcess").status == 0) {
                    $("#commitBtn").show();
                }
                $("#applyUserName").val(model.get("approvalProcess").applyUserName);
                $("#applyUserId").val(model.get("approvalProcess").applyUserId);
                $("#type").val(model.get("approvalProcess").type);
                if (model.get("approvalProcess").status == 0) {
                    $("#commitBtn").show();
                }
                if (model.get("contractType") != null) {
                    if (model.get("contractType") == 1) {
                        $("#contractType").val("采购");
                    } else if (model.get("contractType") == 2) {
                        $("#contractType").val("凭租");
                    } else if (model.get("contractType") == 2) {
                        $("#contractType").val("合作");
                    } else if (model.get("contractType") == 3) {
                        $("#contractType").val("服务");
                    } else if (model.get("contractType") == 5) {
                        $("#contractType").val("其他");
                    }
                }
                if (model.get("contractType") == 5) {
                    $("#othertr").show();
                }
                if (model.get("payType") != null) {
                    if (model.get("payType") == 1) {
                        $("#payType").val("电汇");
                    } else if (model.get("payType") == 2) {
                        $("#payType").val("支票");
                    } else if (model.get("payType") == 3) {
                        $("#payType").val("现金");
                    } else if (model.get("payType") == 4) {
                        $("#payType").val("个人垫付");
                    } else if (model.get("payType") == 5) {
                        $("#payType").val("对公转账");
                    }
                }
                $("#other").text(model.get("other"));
                if (model.get("invoiceContent") != null) {
                    if (model.get("invoiceContent") == 1) {
                        $("#invoiceContent").val("装修款");
                    }
                }
                var txt = "<a href=\"javascript:viewProject(" + model.get("projectId") + ");\">查看详情</a>";
                $("#toView").html(txt);

                process_id = model.get("approvalProcess").id;

                loadRecord(process_id);
            }

            getAffixs();
            loadRecord(process_id);
        }

        function viewProject(id) {
            var msg = "供应商评审表";
            var url = "projectsupplier_view.html?id=" + id;
            parent.addTabs("查看" + msg + "-" + id, contextPath + "system/qdzxapproval/approval/" + url + "&_pfrid=" + $.getUrlParam("_frid"));
        }

        ////加载领导审核意见
        function loadRecord(process_id) {
            $.ajax({
                type: "POST",
                url: contextPath + "manager/approvalRecords/listApprovalRecord/" + process_id,
                data: {},
                dataType: "json",
                success: function (data) {
                    if (data) {
                        var rHtml = "";
                        var msg = "审核"
                        for (var i = 0; i < data.length; i++) {
                            if (data[i].userType == 5) {
                                msg = "复核";
                            } else {
                                msg = "审核"
                            }
                            rHtml += "<div style=\"margin-top:8px;margin-bottom:8px;\">" + msg + "人：" + data[i].approvalUser.truename + "";
                            if (data[i].approvalDate == null) {
                                rHtml += "<span style=\"margin-left:15px;\">尚未" + msg + "</span>";
                            } else {
                                rHtml += "<span style=\"margin-left:15px;\">" + msg + "时间：" + data[i].approvalDate + "</span>";
                                if (data[i].approvalType == 1) {
                                    rHtml += "<span style=\"margin-left:15px;\">" + msg + "选项：同意</span>";
                                } else {
                                    rHtml += "<span style=\"margin-left:15px;\">" + msg + "选项：不同意</span>";
                                }
                                rHtml += "<span style=\"margin-left:15px;\">" + msg + "意见：" + data[i].opinion + "</span>";
                            }
                            rHtml += "</div>";
                        }
                        $("#showRecords").html(rHtml);
                    }
                },
                error: function (response) {
                    $.messager.alert("提示", "出错了，请联系管理员!", 'error', function (rt) {
                        $.messager.alert("提示", response.responseText, 'error');
                    });
                }
            });
        }
        function getAffixs() {
            $.ajax({
                type: "POST",
                url: contextPath + "affixs",
                data: { "objectType": 232, objectId: objectId },
                dataType: "json",
                success: function (data) {
                    if (data && data.length > 0) {
                        showAffixs(data);
                    } else {
                        $("#showFiles").html("");
                    }
                },
                error: function (response) {
                    $.messager.alert("提示", "出错了，请联系管理员!", 'error', function (rt) {
                        $.messager.alert("提示", response.responseText, 'error');
                    });
                }

            });
        }


        function showAffixs(data) {
            var fileHtml = "";
            for (var i = 0; i < data.length; i++) {
                fileHtml += "<div style=\"margin-top:8px;margin-bottom:8px;\">" + data[i].name;
                fileHtml += "<a style=\"margin-left:10px\" href=\"javascript:\" onclick=\"downfile(" + data[i].id + ")\">下载</a>";
            }
            $("#showFiles").html(fileHtml);
        }


        function downfile(affixId) {
            window.location.href = contextPath + 'affix/' + affixId + '/download';
        }	
    </script>
    <div id="loading1"
        style="position: absolute; left: 0px; top: 0px; width: 100%; height: 703px; background: rgb(232, 232, 232); opacity: 0.5; z-index: 10000; display: none;">
    </div>
    <div id="loading2" class="panel-loading"
        style="position: fixed; top: 38%; left: 41%; border: 2px solid rgb(149, 184, 231); width: 160px; font-size: 14px; z-index: 10001; background: url(&quot;/system/jquery/themes/themes1/images/loading-1.gif&quot;) 10px 8px no-repeat rgb(255, 255, 255); display: none;">
        正在处理，请稍等...</div>
</body>